<?php
class commentController extends accessController{
    public static function _right(){
        return array(
            array('评论管理',1),
            array('评论列表','mylist'),
            array('评论编辑','mod,mod_'),
            array('评论删除','del'),
            array('审核评论','update_status'),
        );
    }
	public function s(){
		return array('comment');
	}
	
	public function mylist(){
		$status_data=array('-1'=>'--请选择--','0'=>'隐藏','1'=>'显示');
		$condition=array();
		$extra='';
		
		$id=intval($_GET['id']);//
		if($id){
			$condition['id']=$id;
			$extra.=" and `id`=:id";
			$extra_data['id']=$id;
		}
		
		$arc_id=intval($_GET['arc_id']);//
		if($arc_id){
			$condition['arc_id']=$arc_id;
			$extra.=" and `arc_id`=:arc_id";
			$extra_data['arc_id']=$arc_id;
		}
		
		isset($_GET['status']) or $_GET['status']=-1;
		$status=intval($_GET['status']);//
		if($status>-1){
			$condition['status']=$status;
			$extra.=" and `status`=:status";
			$extra_data['status']=$status;
		}
		
		$ts_1=$_GET['ts_1'];//
		if($ts_1){
			$condition['ts_1']=$ts_1;
			$tmp=strtotime($ts_1);
			$extra.=" and `timestring`>=:ts_1";
			$extra_data['ts_1']=$tmp;
		}
		$ts_2=$_GET['ts_2'];//
		if($ts_2){
			$condition['ts_2']=$ts_2;
			$tmp=strtotime($ts_2);
			$extra.=" and `timestring`<=:ts_2";
			$extra_data['ts_2']=$tmp;
		}
		$return=$this->s_0->mylist($condition,$extra,$extra_data);
		include($this->viewer_dir.'comment/mylist.php');
	}
	public function mod(){
		$id=intval($_GET['id']);
        if($id>0){
            $data=$this->s_0->mod($id);
            if($data){
                include($this->viewer_dir.'comment/mod.php');
            }
        }
	}
	public function mod_(){
		$id=intval($_GET['id']);
        if($_POST and $id>0){
            $r=$this->s_0->mod_($_POST,$id);
            autoalert($r[0],$r[1]);
            back();
        }
	}
	//批量删除
	public function del(){
		if($_GET){
			$id=intval($_GET['id']);
			if($id>0){
				$r=$this->s_0->del($id);
				autoalert($r[0],$r[1]);
				back();
			}
		}
		if($_POST){
			$id=$_POST['items'];
			if(!empty($id)){
				foreach($id as $k=>$v) $this->s_0->del($v);
				alert('删除成功！');
				back();
			}
		}
	}
	public function bit_op(){
		
	}
	//批量更新状态
	public function update_status(){
		if($_GET){
			$id=intval($_GET['id']);
			$status=intval($_GET['status']);
			if($id>0){
				$r=$this->s_0->update_status($id,$status);
				autoalert($r[0],$r[1]);
				back();
			}
		}
		if($_POST){
			$id=$_POST['items'];
			if(!empty($id)){
				$status=intval($_POST['status']);
				foreach($id as $k=>$v) $this->s_0->update_status($v,$status);
				alert('操作成功！');
				back();
			}
		}
	}
//
}